package gml.android.hellosc;

import gml.android.osc.Connection;
import gml.android.osc.NetworkConnection;
import gml.android.osc.OSCConnection;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;

/**
 * An simple {@link Activity} that make an OSC connection; in moment only send OSC messages;
 * trying to receive OSC messages from client 
 * 
 * @see {@link http://stackoverflow.com/questions/3325915/android-activity-establish-network-connection}
 * @see {@link Connection}
 * @see {@link NetworkConnection}
 * @see {@link OSCConnection}
 * @version 0.1
 * @author gcravista.gmail.dot.com
 *
 */
public class HelloAndroidOSC extends Activity {
	
	/** tag to identify this {@link Context} in {@link Log}*/
	private static final String TAG = "HelloAndroidOSC";
	
	private OSCConnection connection;

	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setTitle(getString(R.string.app_name));
		setContentView(R.layout.main);
		
		boolean networkConnected = NetworkConnection.isOnline(this);
		if(networkConnected){
			connection = new OSCConnection(OSCConnection.IP_EMULATOR, 
					OSCConnection.OSC_PORT_SUPERCOLLIDER);
			
			//FIXME: LOG indicate that OSC is not Connected, but is connected and send messages...
			connection.connect(this);
		}
	}
}
